<?php
class SecurityAction extends Action {
	var $permission = '';
	function __construct() {
		parent::__construct ();
		
		// $tmp = unserialize(session('info.permission'));
		// $su = (session('info.su'));
		// foreach($tmp as $key=>$value){
		// $this->permission[$value] = '1';
		// }
		
		if (empty ( session ( 'info.rid' ) )) {
			// exit('请先登录');
			session ( 'info', null );
			session_destroy ();
			$this->error ( '请先登录', '/Admin/console/login' );
			exit ();
			return;
		}
		
		$ob = M ( "csl_role" );
		$per = $ob->where ( array (
				'rid' => session ( 'info.rid' ) 
		) )->find ();
		
		// $ob = M("t_admin_permission");
		// $list = $ob->select();
		// if($su == '1'){
		// foreach($list as $key=>$value){
		// $this->permission[$value['code']] = '1';
		// }
		// }
		// $this->assign('permission',$this->permission);
		
		$this->assign ( "menuFirst", session ( 'menuFirst' ) );
		$this->assign ( "menuSecond", session ( 'menuSecond' ) );
	}
	public function checkPermission($code) {
		if ($this->permission [$code] != 1) {
			exit ( '权限请求错误，请联系管理员' );
		}
	}
}